package com.woniuxy.rms.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.rms.advice.LogPoint;
import com.woniuxy.rms.pojo.Hotlist;
import com.woniuxy.rms.service.HotService;
import com.woniuxy.rms.util.DataResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Auther: ChenGang  <br/>
 * Date: 2020/3/28 0028:上午 10:21  <br/>
 * Description:活动控制层
 */
@Controller
@RequestMapping("/hot")
public class HotController {

    @Autowired
    HotService hotService;

    /**
     * Description : 活动列表查询  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 上午 10:49 [Administrator]);
     * @param currentPage 当前页
     * @param pageSize 页大小
     * @param status 审核状态
     * @param roleId  角色id
     * @return java.util.List<com.woniuxy.rms.pojo.Hotlist>
     */
    @GetMapping("/list")
    @ResponseBody
    @LogPoint("查询活动列表")
    public DataResult list(@RequestParam(defaultValue = "1",required = false,name = "page") Integer currentPage,
                           @RequestParam(defaultValue = "5",required = false,name = "limit") Integer pageSize,
                           @RequestParam(required = false) Integer status,
                           @RequestParam(required = false) Integer roleId){
        List<Hotlist> hotlists = hotService.findByPage(currentPage,pageSize,status,roleId);
        PageInfo info = new PageInfo(hotlists);
        return DataResult.success(info);
    }
    /**
     * Description : 活动审核  <br/>
     * ChangeLog : 1. 创建 (2020/3/28 0028 上午 11:46 [Administrator]);
     * @param id
     * @param status
     * @return com.woniuxy.rms.util.DataResult
    */
    @PutMapping("/hotStatus")
    @ResponseBody
    @LogPoint("活动审核")
    public DataResult hotCheck(Long id,Integer status){
        return hotService.hotStatus(id,status);
    }
}